package cn.zjitc.ptaLearn.ch07.ex13;

import java.util.Scanner;
/**
 * @author Zixuan Xu
 * @date
 */
/*
    首行是一个整数：代表要不要租车 1——要租车（程序继续），0——不租车（程序结束）；
    第二行是一个整数，代表要租车的数量N；
    接下来是N行数据，每行2个整数m和n，其中：m表示要租车的编号，n表示租用该车型的天数。

    若成功租车，则输出一行数据，数据间有一个空格，含义为：
    载客总人数 载货总重量（保留2位小数） 租车金额（整数）
    若不租车，则输出：
    0 0.00 0（含义同上）
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Car[] cars = new Car[10];
        cars[0] = new Car(1,5,0.00,800);
        cars[1] = new Car(2,5,0.00,400);
        cars[2] = new Car(3,5,0.00,800);
        cars[3] = new Car(4,51,0.00,1300);
        cars[4] = new Car(5,55,0.00,1500);
        cars[5] = new Car(6,5,0.45,500);
        cars[6] = new Car(7,5,2.00,450);
        cars[7] = new Car(8,0,3.00,200);
        cars[8] = new Car(9,0,25.00,1500);
        cars[9] = new Car(10,0,35.00,2000);
        int judge = sc.nextInt();
        if(judge==0){
            System.out.println("0 0.00 0");
        }else{
            int count = sc.nextInt();
            int sumCapacity = 0;
            int sumMoney = 0;
            double sumLoad = 0.0;
            for(int i=0;i<count;i++) {
                int number = sc.nextInt();
                int day = sc.nextInt();
                sumCapacity += cars[number-1].getCapacity()*day;
                sumLoad += cars[number-1].getLoad()*day;
                sumMoney += cars[number-1].getMoney()*day;
            }
            System.out.printf("%d %.2f %d",sumCapacity,sumLoad,sumMoney);
        }
    }
}

class Car {
    private int number;
    private int capacity;
    private Double load;
    private int money;

    public Car(){}

    public Car(int number, int capacity, Double load, int money) {
        this.number = number;
        this.capacity = capacity;
        this.load = load;
        this.money = money;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public int getCapacity() {
        return capacity;
    }

    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    public Double getLoad() {
        return load;
    }

    public void setLoad(Double load) {
        this.load = load;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }
}
